package com.ljy.db_bean_builder.config;

import java.util.Properties;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.jndi.JndiObjectFactoryBean;

import com.alibaba.druid.pool.DruidDataSourceFactory;

/** 
* @author James
* @date 2018年6月19日 
*/
@Configurable
public class DbConfig {
	
	@Autowired
	private Environment env;
	
	@Bean("dataSource")
	public DataSource fmEventDbDataSource() throws Exception {
		Properties props = new Properties();
		
//		props.put("driverClassName", env.getProperty("fm_event.datasource.driver-class-name"));
//		props.put("url", env.getProperty("fm_event.datasource.url"));
//		props.put("username", env.getProperty("fm_event.datasource.username"));
//		props.put("password", env.getProperty("fm_event.datasource.password"));
		props.put("driverClassName", "com.mysql.jdbc.Driver");
		props.put("url", "jdbc:mysql://192.168.25.26:3306/findmacau?useUnicode=true&serverTimezone=CTT&characterEncoding=UTF-8&allowMultiQueries=true");
		props.put("username", "root");
		props.put("password", "123456");
		return DruidDataSourceFactory.createDataSource(props);
	}
}
